package com.example.librarymanagement.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.librarymanagement.dao.BorrowRecordMapper;
import com.example.librarymanagement.dto.daily.BookBorrowListDto;
import com.example.librarymanagement.entity.BorrowRecord;
import com.example.librarymanagement.service.IBookBorrowRecordService;
import com.example.librarymanagement.vo.BorrowRecordTopVo;
import org.springframework.stereotype.Service;

/**
 * @author lzx
 */
@Service
public class BookBorrowRecordServiceImpl extends ServiceImpl<BorrowRecordMapper, BorrowRecord> implements IBookBorrowRecordService {

    @Override
    public IPage<BorrowRecordTopVo> getBorrowRecordTopByBook(BookBorrowListDto bookBorrowListDto) {
        Page<BorrowRecordTopVo> page = new Page<>(bookBorrowListDto.getCurrent(), bookBorrowListDto.getSize());
        return baseMapper.getBorrowRecordTopByBook(page, bookBorrowListDto);
    }

    @Override
    public IPage<BorrowRecordTopVo> getBorrowRecordTopByPeriodical(BookBorrowListDto bookBorrowListDto) {
        Page<BorrowRecordTopVo> page = new Page<>(bookBorrowListDto.getCurrent(), bookBorrowListDto.getSize());
        return baseMapper.getBorrowRecordTopByPeriodical(page, bookBorrowListDto);
    }
}
